package br.com.werp.regras.geral.visao.taglib;

import br.com.werp.regras.geral.GerenciadorErros;

import java.io.IOException;

import java.sql.Timestamp;

import java.text.SimpleDateFormat;

import java.util.Locale;

import javax.servlet.jsp.JspWriter;


/**
 * @author Sobreira
 * Criado em 29/08/2005
 */
public class TimeTag extends MasterTag {
    /* (non-Javadoc)
     * @see br.com.werp.regras.geral.visao.taglib.MasterTag#otherDoStartTagOperations()
     */
    public void otherDoStartTagOperations() {
        JspWriter out = pageContext.getOut();

        try {
            String pattern = "EEEE, dd 'de' MMMM 'de' yyyy";
            SimpleDateFormat formatter =
                new SimpleDateFormat(pattern, new Locale("BR"));
            out.println("<b>" +
                formatter.format(new Timestamp(System.currentTimeMillis())) +
                "</b>");
        } catch (Exception e) {
            GerenciadorErros.logarErro(e);

            try {
                out.println(
                    "<font color=red>Erro acessando data e hora no servidor" +
                    " </font>");
            } catch (IOException e1) {
                GerenciadorErros.logarErro(e1);
            }
        }
    }
}
